home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Graphics / Viewers / aa_m68k_Intel_Only / ToyViewer1.2 / Source / ToyWinDraw.m < prev    next >
Encoding:
Text File  |  1995-11-12  |  2.1 KB  |  88 lines

  1. #import <dpsclient/wraps.h>    /* for PSxxx functions */
  2. #import <appkit/Control.h>
  3. #import <appkit/TextField.h>
  4. #import <appkit/ScrollView.h>
  5. #import <appkit/tiff.h>        /* NXImageBitmap */
  6. #import <appkit/graphics.h>
  7. #import <appkit/appkit.h>
  8. #import <stdio.h>
  9. #import <stdlib.h>
  10. #import <string.h>
  11. #import "ToyWin.h"
  12. #import "ToyView.h"
  13. #import "TVController.h"
  14.  
  15.  
  16. @implementation ToyWin (Drawing)
  17.  
  18. - drawView:(unsigned char **)map info:(commonInfo *)cinf
  19. {
  20.     ToyView *view;
  21.     id tmp;
  22.  
  23.     [scView setHorizScrollerRequired: YES];
  24.     [scView setVertScrollerRequired: YES];
  25.     [scView setBorderType: NX_NOBORDER];
  26.     tmp = [[ToyView alloc] setCommText: commentText];
  27.     [tmp setPreference: [controller preference]];
  28.     if ((view = [tmp initDataPlanes:map info:cinf]) == nil) {
  29.         [tmp free];
  30.         return nil;
  31.     }
  32.     if ((tmp = [scView setDocView: view]) != nil)
  33.         [tmp free];
  34.     [scView setCopyOnScroll: YES];
  35.     [thiswindow display];
  36.     [thiswindow makeKeyAndOrderFront: self];
  37.     [commentText setStringValue: cinf->memo];
  38.     NXPing();
  39.     return self;
  40. }
  41.  
  42.  
  43. - (int)drawFromFile:(const char *)fileName or:(NXStream *)stream Num:(int)num
  44. {
  45.     id tmp, view;
  46.     commonInfo *cinf;
  47.  
  48.     [scView setHorizScrollerRequired: YES];
  49.     [scView setVertScrollerRequired: YES];
  50.     [scView setBorderType: NX_NOBORDER];
  51.     tmp = [[ToyView alloc] setCommText: commentText];
  52.     [tmp setPreference: [controller preference]];
  53.     view = stream
  54.         ? [tmp initFromStream: stream]
  55.         : [tmp initFromFile: fileName];
  56.     if (view == nil) {
  57.         [tmp free];
  58.         return Err_OPEN;
  59.     }
  60.     cinf = [view commonInfo];
  61.     [self initLocateWindow:fileName
  62.         Width:cinf->width Height:cinf->height Num:num];
  63.     [self makeComment: cinf];
  64.     [commentText setStringValue: cinf->memo];
  65.     if ((tmp = [scView setDocView: view]) != nil)
  66.         [tmp free];
  67.     [scView setCopyOnScroll: YES];
  68.     [thiswindow display];
  69.     [thiswindow makeKeyAndOrderFront: self];
  70.     NXPing();
  71.     return 0;
  72. }
  73.  
  74. - makeComment:(commonInfo *)cinf
  75. {
  76.     sprintf(cinf->memo, "%d x %d  %dbit%s  %s", cinf->width,
  77.         cinf->height, cinf->bits, ((cinf->bits > 1) ? "s" : ""),
  78.         (cinf->alpha ? "alpha" : ""));
  79.     return self;
  80. }
  81.  
  82. - (int)drawToyWin:(const char *)fileName Type:(int)type Num:(int)num
  83. {
  84.     return [self drawFromFile: fileName or: NULL Num:(int)num];
  85. }
  86.  
  87. @end
  88.